home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
e
/
kyz_obj.lha
/
doc
/
cdplayer.doc
< prev
next >
Wrap
Text File
|
1998-10-18
|
19KB
|
663 lines
TABLE OF CONTENTS
cdplayer.m/--overview--
cdplayer.m/currenttrack
cdplayer.m/discchanged
cdplayer.m/discinserted
cdplayer.m/eject
cdplayer.m/ejected
cdplayer.m/end
cdplayer.m/insert
cdplayer.m/length
cdplayer.m/location
cdplayer.m/maketime
cdplayer.m/open
cdplayer.m/pause
cdplayer.m/paused
cdplayer.m/play
cdplayer.m/playing
cdplayer.m/search
cdplayer.m/spindown
cdplayer.m/spinning
cdplayer.m/spinup
cdplayer.m/stop
cdplayer.m/timeval
cdplayer.m/trackinfo
cdplayer.m/tracks
cdplayer.m/unpause
cdplayer.m/waitfordisc
cdplayer.m/--overview-- cdplayer.m/--overview--
PURPOSE
To provide an interface to the cd.device for playing Audio CDs.
OVERVIEW
This object simulates the high-level idea of 'CD Controls', such
as play(), pause(), stop() and so on. It also allows querying of
the CD drive, such as whether the door is open or if the disc is
spinning.
Audio play is, of course, asynchronous, and the audio can be
manipulated while play is in progress.
Construction and destruction:
open(), end()
CD Controls:
play(), stop(), search()
CD State controls:
pause(), unpause(), paused() - pause control
eject(), insert(), ejected() - door control
spinup(), spindown(), spinning() - motor control
playing(), location()
Disc information:
discchanged(), discinserted(), waitfordisc()
Track information:
length(), tracks(), trackinfo(), currenttrack()
Timing specifications
Audio CDs are marked in minutes, seconds and frames. There are
75 frames in a second, and 60 seconds in a minute.
To work with Audio CDs, there must be some way of representing
a time values. Time values are used to specify positions on
the CD, offsets from the beginning of the CD or tracks, the
length of tracks, the total time on the CD, amounts of time to
be played, and so on.
There are two standard ways to represent time values for CDs.
One is called 'LSN format', where LSN stands for 'Logical
Sector Numbers'. LSN format is basically a mass number of
frames, where a minute is 4500 frames, and a second is 75
frames. The advantage of this format is that times can be
worked with like normal numbers. You can add them, subtract
them and compare them with normal number math.
The other standard time representation is 'MSF format', where
MSF stands for 'Minutes, Seconds, Frames'. Just as an LSN
value is an unsigned 32-bit LONG value, so is an MSF value -
but each byte of the LONG is used individually to store a
minute count, second count, and a frame count. The most
significant byte is unused, the next most significant byte is
a number from 0 to 255 representing the number of minutes, the
next byte is a number from 0 to 59 representing the number of
seconds, and the least significant byte holds a value from -
to 74 containing a number of frames.
A fair analogy for MSF format would be the well known Binary
Coded Decimal (BCD) format supported by most processors. The
numbers cannot be added or manipulated without special
instructions, and 'invalid' values are possible, but the
values themselves are more readable and 'splittable' than
normal integers.
Before an argument breaks out, it must be said that this class
always uses LSN format time values - in all instances. It is
far more practical to do so than to support MSF format.
However, there are two functions to provide the functionality
inherent in the MSF format. maketime() will take a number of
minutes, seconds and frames, and create an LSN format number
from them. timeval() will take an LSN format number, and
return a number of minutes, seconds and frames.
The unit of time value measurement is referred to as 'frames'.
Error handling
When the functions of the cdplayer object mention 'failure',
'errors' and so on, they refer to logical errors that the
functions specifically expect and report. However, they do not
expect I/O errors with the CD device. If the CD device
returns an errors, the exception CDPERR_DEVICE will be thrown,
and the device error will be in exceptioninfo. In their normal
operation, the functions do not cause or expect any device
errors. However, events beyond their control can cause them.
In practise, it is very difficult to cause them.
cdplayer.m/currenttrack cdplayer.m/currenttrack
NAME
cdplayer.currenttrack() -- report track being played.
SYNOPSIS
track := currenttrack()
FUNCTION
Returns the latest known currently playing track. The CD must be
playing, but it does not matter if play is paused or searching.
RESULT
track - CDTRACK_INVALID if the CD is not playing, otherwise the
track number.
SEE ALSO
play(), playing(), location()
cdplayer.m/discchanged cdplayer.m/discchanged
NAME
cdplayer.discchanged() -- report if disc has been changed.
SYNOPSIS
changed := discchanged()
FUNCTION
This function returns TRUE if the disc in the CD drive has changed
since you last called this function. To help you, the function is
called automatically on your behalf when you first create the
cdplayer object.
RESULT
changed - TRUE if the disc in the CD drive has changed since this
function was last called, FALSE otherwise.
NOTE
A disc change does not imply that there is a disc in the drive!
SEE ALSO
discinserted(), waitfordisc()
cdplayer.m/discinserted cdplayer.m/discinserted
NAME
cdplayer.discinserted() -- report if a disc is in the drive.
SYNOPSIS
inserted := discinserted()
FUNCTION
Reports if a readable disc is ready and in the CD drive.
RESULT
inserted - TRUE if a disc is inserted, FALSE otherwise.
NOTE
Discs may be removed at any time, even just after this call has
returned TRUE! A TRUE result from this function is no guarantee of
permanent disc availability.
SEE ALSO
discchanged(), waitfordisc()
cdplayer.m/eject cdplayer.m/eject
NAME
cdplayer.eject() -- open the CD drawer/door.
SYNOPSIS
eject()
FUNCTION
Requests the CD drive to open its drawer or door.
NOTE
You must have a CD drive with a motorized drawer or door for this
call to work. The CD³² drive throws IO error CDERR_NOCMD.
SEE ALSO
insert(), ejected()
cdplayer.m/ejected cdplayer.m/ejected
NAME
cdplayer.ejected() -- report if CD drawer/door is open.
SYNOPSIS
door_open := ejected()
FUNCTION
Reports the current state of the CD drawer or door.
RESULT
Returns TRUE if the door is open, FALSE otherwise.
NOTE
Cartridge-based CD drives do not normally report being 'open'.
SEE ALSO
eject(), insert()
cdplayer.m/end cdplayer.m/end
NAME
cdplayer.end() -- Destructor.
SYNOPSIS
end()
FUNCTION
Frees resources used by an instance of the cdplayer class.
SEE ALSO
new()
cdplayer.m/insert cdplayer.m/insert
NAME
cdplayer.insert() -- close the CD drawer/door.
SYNOPSIS
insert()
FUNCTION
Requests the CD drive to close its drawer or door.
NOTE
You must have a CD drive with a motorized drawer or door for this
call to work. The CD³² drive throws IO error CDERR_NOCMD.
SEE ALSO
eject(), ejected()
cdplayer.m/length cdplayer.m/length
NAME
cdplayer.length() -- report the running time for the CD.
SYNOPSIS
length := length()
FUNCTION
Returns the length in time of the CD currently inserted.
RESULT
length - A time value in frames, or CDTIME_INVALID in error.
SEE ALSO
tracks()
cdplayer.m/location cdplayer.m/location
NAME